package dataStructure.xmg1.a10;

import dataStructure.xmg1.a10.printer.BinaryTrees;
import dataStructure.xmg1.a10.tree.AVLTree;
import dataStructure.xmg1.a10.tree.RBTree;

/**
 * @author: vince_zww
 * @date: 2020/12/13 23:04
 * @desceription:
 */
public class Main {

    static void test2() {
        Integer data[] = new Integer[]{
                7, 4
                , 9, 2, 5, 8, 11, 3, 12, 1, 10,18,22,99
        };

        AVLTree<Integer> avl = new AVLTree<>();
        for (int i = 0; i < data.length; i++) {
            avl.add(data[i]);
            BinaryTrees.println(avl);
        }
        avl.remove(99);
        avl.remove(22);
        avl.remove(12);
        avl.remove(18);
        BinaryTrees.println(avl);

    }

    static void test1() {
        Integer data[] = new Integer[]{
                7, 4
                , 9, 2, 5, 8, 11, 3, 12, 1, 10,18,22,99
        };

        AVLTree<Integer> avl = new AVLTree<>();
        for (int i = 0; i < data.length; i++) {
            avl.add(data[i]);
            System.out.println("【"+data[i]+"】");
            BinaryTrees.println(avl);
            System.out.println("-----------------------------------");
        }
        BinaryTrees.println(avl);

    }

    static void test3() {
        Integer data[] = new Integer[]{
                67,52,92,96,53,95,13,63,34,82,76,54,9,68,39
        };

        RBTree<Integer> rb = new RBTree<>();
        for (int i = 0; i < data.length; i++) {
            rb.add(data[i]);
            System.out.println("【"+data[i]+"】");
            BinaryTrees.println(rb);
            System.out.println("-----------------------------------");
        }
        BinaryTrees.println(rb);

    }

    static void test4() {
        Integer data[] = new Integer[]{
                67,52,92,96,53,95,13,63,34,82,76,54,9,68,39
        };

        RBTree<Integer> rb = new RBTree<>();
        for (int i = 0; i < data.length; i++) {
            rb.add(data[i]);
            System.out.println("【"+data[i]+"】");
            BinaryTrees.println(rb);
            System.out.println("-----------------------------------");
        }
        BinaryTrees.println(rb);

        for (int i = 0; i < data.length; i++) {
            rb.remove(data[i]);
            System.out.println("-----------------------------------");
            System.out.println("【"+data[i]+"】");
            BinaryTrees.println(rb);
        }

    }

    public static void main(String[] args) {
        test4();
    }
}
